package com.usdt.web.core.config;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.usdt.common.core.domain.entity.SysUser;
import com.usdt.framework.web.service.SysPermissionService;
import com.usdt.system.service.ISysUserService;

import cn.dev33.satoken.stp.StpInterface;

@Component
public class StpInterfaceImpl implements StpInterface {
	
	@Autowired
    private SysPermissionService permissionService;
	@Autowired
    private ISysUserService userService;

	@Override
	public List<String> getPermissionList(Object loginId, String loginType) {
		Long userId = Long.parseLong(loginId.toString());
    	SysUser user = userService.selectUserById(userId);
        // 权限集合
        List<String> permissions = permissionService.getMenuPermission(user);
		return permissions;
	}

	@Override
	public List<String> getRoleList(Object loginId, String loginType) {
		Long userId = Long.parseLong(loginId.toString());
    	SysUser user = userService.selectUserById(userId);
        // 角色集合
        List<String> roles = permissionService.getRolePermission(user);
        return roles;
	}

}
